//
//  NSString+XiangAddition.m
//  RootDirectory
//
//  Created by JuYuFeng on 16/5/30.
//  Copyright © 2016年 Ryan. All rights reserved.
//

#import "NSString+XiangAddition.h"

@implementation NSString (XiangAddition)
+ (NSString *)stringByJsonFile:(NSString *)fileName
{
    NSString *str = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileName ofType:@"json"]
                                              encoding:NSUTF8StringEncoding
                                                 error:nil];
    return str;
}

+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString
{
    if (jsonString == nil)
    {
        return nil;
    }
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
    if(err)
    {
        NSLog(@"json解析失败：%@",err);
        return nil;
    }
    return dic;
}

@end
